package cat.music.ut

import android.app.Application
import cn.u313.livefeature.component.sp.SpProperty
import org.koin.android.ext.koin.androidContext
import org.koin.android.ext.koin.androidLogger
import org.koin.core.context.GlobalContext.startKoin
import org.koin.dsl.module
import org.koin.java.KoinJavaComponent

class CatApp: Application() {

    private val userSp: SpProperty by KoinJavaComponent.inject(SpProperty::class.java)

    companion object {
        lateinit var app: CatApp
        fun getInstance(): CatApp {
            return app
        }
    }

    override fun onCreate() {
        super.onCreate()
        app = this

        startKoin {
            androidLogger()
            androidContext(this@CatApp)
            modules(
                module {
                    single { SpProperty() }
                }
            )
        }
        userSp.init(this)
        initLang()
    }

    private fun initLang() {

    }

    fun getSp(): SpProperty {
        return userSp
    }


}